/*
 * @Author: 霍雷
 * @Date: 2022-05-23 15:01:37
 * @LastEditors: 霍雷
 * @LastEditTime: 2022-05-24 16:43:14
 * @FilePath: \gua-dev-starter\dev-kit\vite\plugins\pages.ts
 * @Discription:
 */
import Pages from 'vite-plugin-pages'
// 模块存放的目录地址
const MODULE_PATH = 'src/modules'
import { mergeRouterPath } from '../../util/vite-plugin-pages-helper'
const createPages = () => {
  // 路由生成配置
  return Pages({
    dirs: MODULE_PATH,
    onRoutesGenerated: (routes) =>
      routes.map((router) => {
        router.path = mergeRouterPath(router.path)
        return router
      }),
    extensions: ['vue'],
  })
}
export default createPages
